/**
 * Copyright (C), 2020-2021
 * FileName: PurseController
 * Author:   86189
 * Date:     2021/3/8 23:09
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.itheima.wallet.web.controller;

import com.itheima.wallet.pojo.Account;
import com.itheima.wallet.pojo.Trade;
import com.itheima.wallet.web.service.PurseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 〈一句话功能简述〉<br> 
 * 〈钱包〉
 *
 * @author 86189
 * @create 2021/3/8
 * @since 1.0.0
 */
@RestController
@RequestMapping("/purse")
public class PurseController {

    @Autowired
    private PurseService purseService;

    /**
     * 充值
     * @param token
     * @param money
     * @return
     */
    @PostMapping("/chongzhi")
    public Boolean chongzhi(@RequestHeader("token") String token, @RequestParam("money") Double money){
        Boolean b = purseService.chongzhi(token,money);
        return b;
    }

    /**
     * 提现
     * @param token
     * @param money
     * @return
     */
    @PostMapping("/tixian")
    public Boolean tixian(@RequestHeader("token") String token, @RequestParam("money") Double money){
        Boolean b = purseService.tixian(token,money);
        return b;
    }

    /**
     * 查看流水
     * @param token
     * @return
     */
    @GetMapping("/selecttrade")
    public List<Trade> selecttrade(@RequestHeader("token") String token){
        List<Trade> tradeList = purseService.selecttrade(token);
        return tradeList;
    }

    /**
     * 查看账户信息
     * @param token
     * @return
     */
    @GetMapping("/selectaccount")
    public Account selectaccount(@RequestHeader("token") String token){
        Account account = purseService.selectaccount(token);
        return account;
    }


}
